program example_sparse
    use sparseoperator
    implicit none
    type(dsparse) :: dA, dB, dC
    integer :: m, nnz

    call sp_d_allocate(dA,5,15)
    call sp_d_allocate(dB,5,15)
    call sp_d_allocate(dC,5,15)

    call sp_d_create( (/5:1:-1,1:4,2:5/), (/5:1:-1,2:5,1:4/), real((/1:5,1:4,1:4/),8), dA, 5)
    call sp_d_create( (/5:1:-1,1:4,2:5/), (/1:5,2:5,1:4/), real((/1:5,1:4,1:4/),8), dB, 5)
    call sp_d_add(dA,2.d0,dB,dC,5,5,'n')
    print*, '===== A is ========='
    call sp_d_show(dA,'f6.1')
    print*, '===== B is ========='
    call sp_d_show(dB,'f6.1')
    print*, '===== A+B is ========='
    call sp_d_show(dC,'f6.1')
    call sp_d_details(dC)

    print*, '===== A*B is ========='
    call sp_d_mult(dA,dB,dC,5,5,5,'n')
    call sp_d_show(dC,'f6.1')
    call sp_d_details(dC)

    call sp_d_destroy(dA,dB,dC)
    call sp_d_details(dC)


!     call sp_d_destroy(dA)
end program example_sparse